/* Copyright (c) 2004-2022 peigen.info. All rights reserved. */

package info.peigen.hotpot.common.core.domain;

import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.StrUtil;
import info.peigen.hotpot.common.core.annotation.Comment;
import info.peigen.hotpot.common.core.enums.CountryCode;
import lombok.*;
import lombok.experimental.Accessors;
import lombok.experimental.FieldDefaults;
import lombok.experimental.SuperBuilder;

/**
 * <b>(Address)</b>
 * 地址信息
 *
 * @author Peigen
 * @version 1.0.0
 * @since 2021/7/28
 */
@SuperBuilder
@Data
@NoArgsConstructor
@AllArgsConstructor
@FieldDefaults(level = AccessLevel.PRIVATE)
@Accessors(chain = true)
public class Address {
    @Comment(value = "地区")
    @Builder.Default
    CountryCode countryCode = CountryCode.CN;
    @Comment(value = "国家")
    @Builder.Default
    String      nation      = CountryCode.CN.countryName();
    @Comment(value = "省\\州 - Code")
    String      provinceCode;
    @Comment(value = "省\\州 - Name")
    String      provinceName;
    @Comment(value = "城市 - Code")
    String      cityCode;
    @Comment(value = "城市 - Name")
    String      cityName;
    @Comment(value = "区 - Code")
    String      areaCode;
    @Comment(value = "区 - Name")
    String      areaName;
    @Comment(value = "街道 - Code")
    String      streetCode;
    @Comment(value = "街道 - Name")
    String      streetName;
    @Comment(value = "地址,有些时候不遵循省市则填写这个属性")
    String      addressStr;
    @Comment(value = "经度")
    Long        longitude;
    @Comment(value = "维度")
    Long        latitude;

    public void check() {
        notEmptyCheck();
    }

    public void notEmptyCheck() {
        Assert.isTrue(StrUtil.isAllNotBlank(nation, provinceCode, provinceName, cityCode, cityName, areaCode, areaName));
    }

    public String getAddress() {
        return nation + provinceName + cityName + areaName;
    }

}